package com.example.topguli;

import java.sql.SQLOutput;
import java.util.concurrent.*;

public class ThreadPollTest {
    public static void main(String[] args) {
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(2,
                Runtime.getRuntime().availableProcessors(), 3, TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(3), Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy());
        for (int i = 0; i < 30; i++) {
            threadPoolExecutor.execute(new Thread(()->{
                System.out.println(Thread.currentThread().getName());
            }));
        }
        threadPoolExecutor.shutdown();
    }
}
